<script setup>
import { ref } from "vue";
import { problemListApi } from "@/services/user";
import { onLoad, onShow, onReachBottom } from "@dcloudio/uni-app";

onLoad(() => {
  getList();
});

const problemList = ref([]);
const form = ref({ page: 1, limit: 20 });
const status = ref("more");
const getList = async () => {
  try {
    status.value = "loading";
    // 发送请求
    let res = await problemListApi(form.value);
    if (res.code == 200) {
      let arr = [];
      arr = res.data.list;
      problemList.value = problemList.value.concat(arr);
      if (res.data.list.length < form.value.limit) {
        status.value = "no-more";
      } else {
        status.value = "more";
      }
      form.value.page++;
    }
  } catch (e) {
    uni.showToast({
      title: e.info,
      icon: "none",
    });
  }
};

const goDetail = (id) => {
  uni.navigateTo({
    url: "/pages/mine/questionAnswerDeatils?id=" + id,
  });
};
</script>
<template>
  <view class="userAgreement">
    <view class="userAgreement-top">
      <view class="userAgreement-title">问题解答</view>
      <view class="list" v-show="problemList && problemList.length > 0">
        <view
          class="list-box"
          v-for="(item, index) in problemList"
          :key="index"
          @click="goDetail(item.id)"
        >
          <view class="list-box-left">
            <text>{{ item.ask }}</text>
            <!-- <text class="list-box-left-text">{{item.intro}}</text> -->
          </view>
          <view class="list-box-right">
            <image
              src="@/static/my/icon-right-green.png"
              mode="widthFix"
            ></image>
          </view>
        </view>
      </view>
      <view class="nodate-bt" v-if="problemList.length === 0">
        <image src="/static/nodate/datas.png" mode="widthFix"></image>
      </view>
    </view>
  </view>
</template>
<style lang="scss" scoped>
@import "questionAnswer.scss";
</style>
